package com.example.controller;

import com.example.entity.authority.PartyContract;
import com.example.entity.authority.PartyContractProject;
import com.example.service.PartyContractService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * Created by youkun on 2018/3/18.
 */
@RestController
@RequestMapping("api/partyContract")
public class PartyContractController {

    @Autowired
    private PartyContractService partyContractService;

    @ApiOperation(value = "添加机构合同",notes = "添加机构合同")
    @RequestMapping(value="/add",method = RequestMethod.POST)
    Map<String,Object> add(@RequestBody PartyContract partyContract) {

        return partyContractService.add(partyContract);
    }

    @ApiOperation(value = "查询机构合同列表",notes = "查询机构合同列表")
    @RequestMapping(value="/queryByPartyIdList",method = RequestMethod.POST)
    Map<String,Object> queryByPartyIdList(@RequestBody PartyContract partyContract) {

        return partyContractService.queryByPartyIdList(partyContract);
    }

    @ApiOperation(value = "删除机构合同",notes = "删除机构合同")
    @RequestMapping(value="/deleteById/{id}",method = RequestMethod.POST)
    Map<String,Object> deleteById(@PathVariable String id) {
        return partyContractService.deleteById(id);
    }

    @ApiOperation(value = "机构合同id查询附件",notes = "机构合同id查询附件")
    @RequestMapping(value="/queryByPartyIdFile/{id}",method = RequestMethod.POST)
    Map<String,Object> queryByPartyIdFile(@PathVariable String id) {
        return partyContractService.queryByPartyIdFile(id);
    }

    @ApiOperation(value = "修改机构合同列表",notes = "修改机构合同列表")
    @RequestMapping(value="/updateContract",method = RequestMethod.POST)
    Map<String,Object> updateContract(@RequestBody PartyContract partyContract) {

        return partyContractService.updateContract(partyContract);
    }

    @ApiOperation(value = "添加合同项目",notes = "添加合同项目")
    @RequestMapping(value="/addProject",method = RequestMethod.POST)
    Map<String,Object> addProject(@RequestBody PartyContractProject partyContractProject){
        return partyContractService.addProject(partyContractProject);
    }

    @ApiOperation(value = "查询合同项目",notes = "查询合同项目")
    @RequestMapping(value="/queryProject",method = RequestMethod.POST)
    Map<String,Object> queryProjectByContractId(@RequestBody PartyContractProject partyContractProject){
        return partyContractService.queryProjectByContractId(partyContractProject);
    }

    @ApiOperation(value = "删除合同项目",notes = "删除合同项目")
    @RequestMapping(value="/deleteProject",method = RequestMethod.POST)
    Map<String,Object> deleteProject(@RequestBody Map<String, Object> map){
        return partyContractService.deleteProject(map);
    }

    @ApiOperation(value = "更新合同项目",notes = "删除合同项目")
    @RequestMapping(value="/updateProject",method = RequestMethod.POST)
    Map<String,Object> updateProject(@RequestBody PartyContractProject partyContract){
        return partyContractService.updateProject(partyContract);
    }

}

